import Router from 'vue-router'
import Vue from 'vue'
import getQueryString from '../api/url'
import auth from '../api/auth'

Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/index',
      component: resolve => require(['../page/index.vue'], resolve)
    },
    {
      path: '/choose',
      component: resolve => require(['../page/choose.vue'], resolve)
    },
    {
      path: '/choose1',
      component: resolve => require(['../page/choose1.vue'], resolve)
    },
    {
      path: '/active',
      component: resolve => require(['../page/active.vue'], resolve)
    },
    {
      path: '/comment',
      component: resolve => require(['../page/comment.vue'], resolve)
    },
    {
      path: '/love',
      component: resolve => require(['../page/love.vue'], resolve)
    },
    {
      path: '/view',
      component: resolve => require(['../page/view.vue'], resolve)
    },
    {
      path: '/discourse',
      component: resolve => require(['../page/discourse.vue'], resolve)
    },
    {
      path: '/discourse-list',
      component: resolve => require(['../page/discourse-list.vue'], resolve)
    },
    {
      path: '*',
      component: () => {
        router.replace({
          path: '/index'
        })
      }
    }
  ]
})

router.beforeEach((to, from, next) => {
  next()
  // if (getQueryString('openid')) {
    // next()
  // } else {
    // auth()
  // }
})

export default router
